# File description -------------------------------------------------------------

# Replication file: Appendix

# Title: Right-wing terror, media backlash, and voting preferences for the far right
# Authors: Alexander De Juan, Felix Haass, Julian Voss

# Date: 01.05.2025


# Load libraries ----------------------------------------------------------

library(tidyverse)
library(ggrepel)
library(patchwork)
library(fixest)
library(broom)
library(haven)
library(ggtext)
library(fastDummies)
library(marginaleffects)
library(modelsummary)
library(tinytable)
library(sjlabelled)
library(scales)

# Load data ---------------------------------------------------------------

# WVS data on media sources 
wvs_cpds_data <- read_rds("./data/wvs_cpds_data.rds")

# RTV & aggregated voting data
rtv_timeline_ag <- read_rds("./data/rtv_timeline_ag.rds")
voting_timeline_data <- read_rds("./data/voting_timeline_data.rds")

# main Forsabus data
fb_2019_2020_models <- read_rds("./data/forsa_data_hanau.rds")

# survey data
bilendi_survey <- read_rds("./data/bilendi_survey.rds")

# Google trend data
terror_gtrend <- read_rds("./data/anschlag_hanau.rds")
hanau_gtrend <- read_rds("./data/hanau.rds")

# Tweets for Covid-19 analysis
tweets <- read_rds("./data/tweets_hanau_halle_wolfhagen_reshaped_11_10_2023.rds")

# Data on attitudes towards refugees for alt. explanation tests
refugee_survey <- read_rds("./data/refugee_survey.rds")

# Newspaper articles
hanau_articles_coded <- read_rds("./data/hanau_articles_coded.rds")
hanau_articles_pol_leaning <- read_rds("./data/hanau_articles_pol_leaning.rds")
hanau_articles <- read_rds("./data/hanau_articles.rds")

# Define covariates -------------------------------------------------------

## NOTE! Several analyses below require these covariate vectors to be set, 
## so please make sure these are defined when you rund individual analyses, 
## otherwise there will be an error message!


# define covariates for Forsabus
covariates <- c(
  "male",
  "bland", 
  "birth_decade", 
  "income", 
  "education", 
  "occupation_status", 
  "sample", 
  "religion", 
  "children", 
  "family_status"
)


# define PAP covariates for survey experiment
cov_full_pap  <- c("male",
                   "age",
                   "factor(education)",
                   "political_interest",
                   
                   "party_preference_pre_1", 
                   "party_preference_pre_2", 
                   "party_preference_pre_3", 
                   "party_preference_pre_4", 
                   "party_preference_pre_5", 
                   "party_preference_pre_6"
)


# Figure A.1:  Main sources of information in OECD countries -----------

p_media_sources <-
  wvs_cpds_data %>%
  mutate(
    na = ifelse(COUNTRY_ALPHA == "AUS" | wave == 6, "Missing", "Complete"),
    prrp_existent = ifelse(prrp_seats > 0 | prrp_share > 0, "yes", "no")
    ) %>%
  ggplot(aes(x = cname, y = value, fill = name)) +
  geom_bar(stat = "summary", fun = "mean", width = .7,
           position = position_dodge(width = .8, preserve = "single"), color = "black") +
  scale_fill_manual("", values = c("grey60", "grey80"),
                    labels = c("Traditional media", "Social media")) +
  scale_alpha_manual(values = c("Missing" = 0, "Complete" = 1), guide = "none") +
  scale_x_discrete(labels = label_wrap_gen(10)) +
  ylim(0, 1) +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 0, size = 7.5),
        legend.position = "bottom",
        panel.grid = element_blank()) +
  labs(x = "", y = "Share respondents")

ggsave("./figures/figure_A.1_media_sources.pdf", p_media_sources, height = 5, width = 8)

# * Forsa-Bus analysis * -----------------------------------------------------




# Figure B.2: Google search interest ----------------------------------


terror_trend <- terror_gtrend$interest_over_time %>% 
  mutate(date = ymd(date)) %>% 
  ggplot(., aes(x = date, y = hits)) + 
  geom_vline(xintercept = as.Date("2020-02-20"), 
             linetype = "dashed") +
  geom_line() +
  theme_bw() + 
  theme(panel.grid = element_blank()) +
  labs(x = "Date", y = "Search interest",
       title = "\'Anschlag\' (attack) ")

hanau_trend <- hanau_gtrend$interest_over_time %>% 
  mutate(date = ymd(date)) %>% 
  ggplot(., aes(x = date, y = hits)) + 
  geom_vline(xintercept = as.Date("2020-02-20"), 
             linetype = "dashed") +
  geom_line() +
  theme_bw() + 
  theme(panel.grid = element_blank()) +
  labs(x = "Date", y = "Search interest",
       title = "\'Hanau\'  ")



main_interest_plot <- (terror_trend + hanau_trend)  &
  scale_x_date(date_breaks = "8 days", 
               date_labels = "%b %d")

main_interest_plot

ggsave(main_interest_plot, filename = "./figures/figure_B.2_google_trend.pdf", 
       width = 11, height = 3.75, scale = 0.75)



# Figure B.3: Covariate balance -------------------------------------------



# NOTE: repeat this for each covariate

balance_out <- list()
counter <- 1

balance_data <- fb_2019_2020_models  %>%
  filter(days_new %in% c(-5:4)) %>% 
  mutate(across(all_of(covariates), \(x) sjlabelled::as_label(x))) %>%
  select(covariates, post_hanau)

for(covariate in covariates) {
  
  temp_bal_data <- balance_data %>% 
    # change covariate here, e.g. male, bland, etc. 
    group_by(post_hanau, across(all_of(covariate)))  %>% 
    count() %>% 
    group_by(post_hanau) %>% 
    mutate(n_sum = sum(n)) %>% 
    # and here
    group_by(across(all_of(covariate)), post_hanau) %>% 
    summarise(out = Hmisc::binconf(n[1], n_sum))
  
  temp_bal_data <- bind_cols(temp_bal_data[, 1:2], 
                             temp_bal_data[, 3] %>% as.matrix %>% cbind %>% data.frame %>% tibble )
  
  names(temp_bal_data) <- c(covariate, "post_hanau", "share", "lower_ci", "upper_ci")
  
  temp_bal_data <- temp_bal_data %>% 
    pivot_longer(cols = -c(1:2)) %>% 
    mutate(covariate = all_of(covariate))
  
  names(temp_bal_data)[1] <- "cov_value"
  
  balance_out[[counter]] <- temp_bal_data
  counter <- counter + 1
}

balance_out <- map_dfr(balance_out, bind_rows, .id = "id")

balance_out <- balance_out %>% 
  pivot_wider(names_from = name, values_from = value)

balance_plot <- balance_out %>% 
  ggplot(., aes(x = cov_value, y = share, 
                fill = factor(post_hanau))) + 
  geom_col(position = position_dodge(width =1)) + 
  geom_point(position = position_dodge(width = 1), size = 0.5) + 
  geom_errorbar(aes(ymin = lower_ci, ymax = upper_ci), position = position_dodge(width = 1), 
                width = 0, linewidth = 0.25) + 
  facet_wrap(~covariate, scale = "free", ncol = 3) +
  coord_flip() +
  theme_bw() + 
  theme(panel.grid = element_blank(), 
        legend.position = "bottom") +
  scale_fill_manual("Treatment status", 
                    values = c( "grey88","grey55"), 
                    labels = c("pre-Hanau/control", "post-Hanau/treated")) +
  labs(x = "", y = "") 


balance_plot

ggsave(balance_plot, filename = "./figures/figure_B.3_covariate_balance.pdf", 
       width = 11, height = 12.5, scale = 0.8)



# Figure B.4: Multiple bandwidths ---------------------------------------


# ltw preferences
bw <- c(1:15)
index <- 1

temp_data <- fb_2019_2020_models 

coefs <- list()

for(bw_entry in bw) {
  
  temp_mod <- feols(c(
    ltw_afd_intention) ~
      post_hanau
    | sw0(.[covariates]),
    se = "hetero",
    data = temp_data %>%
      filter(days_new %in% c(-bw_entry:(bw_entry-1))))
  
  temp_mod <- map_dfr(temp_mod, tidy, conf.int = T, .id = "model") %>% 
    mutate(bw = bw_entry, 
           donut = FALSE) %>% 
    filter(term == "post_hanau") %>% 
    mutate(model = c("no covariates", "covariates"))
  
  
  coefs[[index]] <- bind_rows(temp_mod)
  
  index <- index + 1
  
}


coefs_ltw <- coefs %>% 
  map_dfr(as_tibble)

# btw preferences
bw <- c(1:15)
index <- 1

temp_data <- fb_2019_2020_models 


coefs <- list()

for(bw_entry in bw) {
  
  temp_mod <- feols(c(
    btw_afd_intention) ~
      post_hanau
    | sw0(.[covariates]),
    se = "hetero",
    data = temp_data %>%
      filter(days_new %in% c(-bw_entry:(bw_entry-1))))
  
  
  temp_mod <- map_dfr(temp_mod, tidy, conf.int = T, .id = "model") %>% 
    mutate(bw = bw_entry, 
           donut = FALSE) %>% 
    filter(term == "post_hanau") %>% 
    mutate(model = c("no covariates", "covariates"))
  
  
  coefs[[index]] <- bind_rows(temp_mod)
  
  index <- index + 1
  
}


coefs_btw <- coefs %>% 
  map_dfr(as_tibble)


coefs_multiple_bw <- bind_rows(
  coefs_ltw %>% mutate(election_type = "ltw"), 
  coefs_btw %>% mutate(election_type = "btw")
)

robcheck_bw_plot <- ggplot(coefs_multiple_bw, aes(x = bw, y = estimate, 
                                                  color = model, shape = model))  +
  geom_hline(yintercept = 0, linetype = "dashed") + 
  
  geom_point(size = 2.5, 
             position = position_dodge(width = 0.75)) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25, 
                position = position_dodge(.75)) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7, 
                position = position_dodge(.75)) +
  theme_bw() +
  scale_color_manual("", 
                     values = c( "grey52", 
                                 "black")) +
  scale_linetype_manual("",values = c("solid", "dashed")) +
  scale_shape_discrete("")  +
  scale_x_continuous(breaks = seq(1, 15)) +
  labs(y = "Coefficient estimate", 
       x = "Bandwidth (in days)") +
  theme(legend.position = "bottom", 
        panel.grid = element_blank()) +
  facet_wrap(~election_type, 
             labeller = labeller(election_type = c("btw" = "Federal elections", 
                                                   "ltw" = "State elections")))

robcheck_bw_plot

ggsave(robcheck_bw_plot, filename = "./figures/figure_B.4_multiple_bandwidths.pdf", 
       width = 12, height = 6, scale = 0.7)




# Figure B.5: Placebo cutoffs ---------------------------------------------

coefs <- list()
counter <- 1

for(window in -10:10) {
  
  temp_data <- fb_2019_2020_models %>% 
    mutate(days_new = days_new + window) %>% 
    filter(days_new %in% c(-5:4)) %>% 
    mutate(post_hanau = ifelse(days_new >= 0, 1, 0))
  
  coef_temp <- feols(ltw_afd_intention ~ 
                       post_hanau 
                     | .[covariates], 
                     se = "hetero",
                     data = temp_data) %>% 
    tidy(., conf.int = T) %>% 
    mutate(window = window)
  
  coefs[[counter]] <- coef_temp
  
  counter <- counter + 1
  
  
  
}


placebo_fals_data <- coefs %>% map_dfr(., as_tibble) %>% 
  filter(!grepl("Intercept", term)) %>% 
  mutate(year = "2020")


placebo_cutoff_plot <- placebo_fals_data %>% 
  ggplot(., aes(x = window, y  = estimate)) +
  geom_rect(aes(xmin = -Inf, xmax = -4.5, ymin = -Inf, ymax = Inf), 
            fill = "grey", alpha = 0.01) + 
  geom_rect(aes(xmin = 4.5, xmax = Inf, ymin = -Inf, ymax = Inf), 
            fill = "grey", alpha = 0.01) + 
  geom_label(data = tibble(label = "Clean placebo", 
                           x = c(-8, 8), y = c(0.06, 0.06)), 
             aes(x = x, y = y, label = label), inherit.aes = F) +  
  geom_label(data = tibble(label = "\'Tainted\' placebo", 
                           x = c(0), y = c(0.06)), 
             aes(x = x, y = y, label = label), inherit.aes = F) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  
  geom_point(size = 2.5, aes(x = window, y = estimate)) +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7) +
  theme_bw() +
  theme(panel.grid = element_blank()) +

  labs(x= "Shifting cutoff by ... days", y = "Coefficient estimate")

placebo_cutoff_plot

ggsave(placebo_cutoff_plot, filename = "./figures/figure_B.5_placebo.pdf", 
       width = 9, height = 5.5, scale = 0.7)


# Figure B.6: Analysis of non-response ------------------------------------


item_nonresp_models <- feols(c(no_answer_ltw_intention, no_answer_btw_intention) ~ 
                               post_hanau 
                             | sw0(.[covariates]), 
                             se = "hetero",
                             data = fb_2019_2020_models %>% 
                               filter(days_new %in% c(-5:4)))

item_nonresp_data <- map_dfr(item_nonresp_models, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau")

item_nonresp_plot <- ggplot(item_nonresp_data, 
                            aes(x = term, y = estimate, 
                                color = cov, 
                                shape = cov))  +
  geom_hline(yintercept = 0, linetype = "dashed") + 
  
  geom_point(size = 2.5, 
             position = position_dodge(width = 0.75)) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25, 
                position = position_dodge(width = 0.75)) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7, 
                position = position_dodge(width = 0.75)) +  
  theme_bw() +
  scale_color_manual("", 
                     values = c( "grey52", "black")) +
  scale_shape_discrete("") +
  scale_x_discrete(labels = c("Post-hanau coefficient", "Post-hanau coefficient")) + 
  facet_wrap(~lhs,labeller = labeller(lhs = c("btw" = "Federal elections voting intentions", 
                                              "ltw" = "State elections voting intentions"))) + 
  
  labs(y = "Treatment effect on non-response", 
       x = "") +
  theme(legend.position = "bottom", 
        panel.grid = element_blank())

item_nonresp_plot

ggsave(item_nonresp_plot, filename = "./figures/figure_B.6_nonresponse.pdf", 
       scale = 0.8, width = 6, height =4)



# Figure B.7: Falsification test ------------------------------------------

coefs <- list()

counter <- 1

for(window in -10:10) {
  
  temp_data <- fb_2019_2020_models %>% 
    mutate(days_new = date - as.Date("2019-02-24"))  %>% 
    mutate(days_new = days_new + window) %>% 
    filter(days_new %in% c(-5:4)) %>% 
    mutate(post_hanau = ifelse(days_new >= 0, 1, 0))
  
  coef_temp <- feols(ltw_afd_intention ~ 
                       post_hanau 
                     | .[covariates], 
                     se = "hetero",
                     data = temp_data) %>% 
    tidy(., conf.int = T) %>% 
    mutate(window = window)
  
  coefs[[counter]] <- coef_temp
  
  counter <- counter + 1
  
  
  
}


placebo_fals_data <- coefs %>% map_dfr(., as_tibble) %>% 
  filter(!grepl("Intercept", term)) %>% 
  mutate(year = "2019")


falsification_dates_plot <- placebo_fals_data %>% 
  ggplot(., aes(x = window, y = estimate)) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25, 
                position = position_dodge(width = 0.75)) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7, 
                position = position_dodge(width = 0.75)) + 
  geom_point(size = 2.5, aes(x = window, y = estimate), 
             position = position_dodge(width = 0.75)) +
  geom_line(aes(x = window, y = estimate, group = year), 
            position = position_dodge(width = 0.75)) +
  
  theme_bw() +
  theme(panel.grid = element_blank(), 
        legend.position = "none") +
  scale_color_manual(values = c("grey50", "black")) +
  scale_linetype_manual(values = c("dotted", "solid")) +
  labs(x= "Shifting cutoff by ... days", y = "Coefficient estimate") +
  facet_wrap(year ~., labeller = labeller(year = c("2019" = "Placebo date: 20 February 2019", 
                                                   "2020" = "Actual date of the attack: February 2020")))

falsification_dates_plot

ggsave(falsification_dates_plot, filename = "./figures/figure_B.7_falsification.pdf", 
       width = 8, height = 5.5, scale = 0.7)




# Figure B.8: Standard errors ---------------------------------------------



se_cluster_days_mod <- feols(c(ltw_afd_intention, btw_afd_intention) ~ 
                               post_hanau 
                             | sw0(.[covariates])
                             , 
                             cluster = "days_new",
                             data = fb_2019_2020_models %>% 
                               filter(days_new %in% c(-5:4)))

se_cluster_days_mod_df <- map_dfr(se_cluster_days_mod, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau") %>% 
  mutate(se = "days")

se_cluster_bland_mod <- feols(c(ltw_afd_intention, btw_afd_intention) ~ 
                                post_hanau 
                              | sw0(.[covariates])
                              , 
                              cluster = "bland",
                              data = fb_2019_2020_models %>% 
                                filter(days_new %in% c(-5:4)))


se_cluster_bland_mod_df <- map_dfr(se_cluster_bland_mod, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau") %>% 
  mutate(se = "bland")

se_cluster_bland_days_mod <- feols(c(ltw_afd_intention, btw_afd_intention) ~ 
                                     post_hanau 
                                   | sw0(.[covariates])
                                   , 
                                   cluster = c("days_new", "bland"),
                                   data = fb_2019_2020_models %>% 
                                     filter(days_new %in% c(-5:4)))

se_cluster_bland_days_mod_df <- map_dfr(se_cluster_bland_days_mod, 
                                        tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau") %>% 
  mutate(se = "bland_days")


alt_se_plots <- bind_rows(
  se_cluster_days_mod_df, 
  se_cluster_bland_mod_df, 
  se_cluster_bland_days_mod_df
) %>% 
  ggplot(., aes(x = term, y = estimate, color = cov, group = cov)) + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  
  geom_point(size = 2.5, 
             position = position_dodge(width = 0.75)) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                position = position_dodge(width = 0.75), width = 0, size = 0.25) + 
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error, ymax = estimate + 1.67 * std.error), 
                position = position_dodge(width = 0.75), width = 0, size = 0.75) + 
  
  theme_bw() +
  theme(panel.grid = element_blank(), 
        legend.position = "bottom") +
  scale_color_manual("", 
                     values = c( "grey52","black")) + 
  scale_x_discrete(labels = c("", "")) +
  facet_grid(se~lhs, 
             labeller = labeller(lhs = c("btw" = "Federal elections", 
                                         "ltw" = "State elections"), 
                                 se = c("bland" = "SE clustered by:\nState", 
                                        "bland_days" = "SE clustered by:\nDays + State", 
                                        "days" = "SE clustered by:\n Days"))) +
  labs(y = "Estimate", 
       x = "Post-Hanau dummy")

alt_se_plots

ggsave(alt_se_plots, filename = "./figures/figure_B.8_SEs.pdf", 
       height = 8, width = 9, scale = 0.75)




# Figure B.9: Survey weights ----------------------------------------------


hanau_ols_noweight <- feols(c(btw_afd_intention, ltw_afd_intention) ~ 
                              post_hanau 
                            | sw0(.[covariates]),
                            se = "hetero",
                            data = fb_2019_2020_models %>% 
                              filter(days_new %in% c(-5:4)))

hanau_ols_noweight_df <- map_dfr(hanau_ols_noweight, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau") %>% 
  mutate(weights = "no weights")


hanau_ols_weight1 <- feols(c(btw_afd_intention, ltw_afd_intention) ~ 
                             post_hanau 
                           | sw0(.[covariates[!grepl("bland|male|birth_decade", covariates)]]),
                           se = "hetero",
                           weights  = ~weight1,
                           data = fb_2019_2020_models %>% 
                             filter(days_new %in% c(-5:4)))

hanau_ols_weight1_df <- map_dfr(hanau_ols_weight1, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau") %>% 
  mutate(weights = "weight1")

hanau_ols_weight2 <- feols(c(btw_afd_intention, ltw_afd_intention) ~ 
                             post_hanau 
                           | sw0(.[covariates[!grepl("bland|male|birth_decade", covariates)]]),
                           se = "hetero",
                           weights  = ~weight2,
                           data = fb_2019_2020_models %>% 
                             filter(days_new %in% c(-5:4)))



hanau_ols_weight2_df <- map_dfr(hanau_ols_weight2, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau") %>% 
  mutate(weights = "weight2")


weights_df <- bind_rows(
  hanau_ols_noweight_df, 
  hanau_ols_weight1_df, 
  hanau_ols_weight2_df
)

weights_df_plot <- weights_df %>% 
  ggplot(., aes(x = term, y = estimate, color = cov, group = cov)) + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  
  geom_point(size = 2.5, 
             position = position_dodge(width = 0.75)) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                position = position_dodge(width = 0.75), width = 0, size = 0.25) + 
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error,
                    ymax = estimate + 1.67 * std.error), 
                position = position_dodge(width = 0.75), 
                width = 0, size = 0.75) + 
  
  theme_bw() +
  theme(panel.grid = element_blank(), 
        legend.position = "bottom") +
  scale_color_manual("", 
                     values = c( "grey52", 
                                 "black")) + 
  scale_x_discrete(labels = c("", "")) +
  facet_grid(weights~lhs, scales = "free_x", 
             labeller = labeller(lhs = c("btw" = "Federal elections", 
                                         "ltw" = "State elections"),
                                 weights = c("no weights" = "No weights", 
                                             "weight1" = "Prior vote choice,\nstate, age gender", 
                                             "weight2" = "State, age, gender"))) +
  labs(y = "Estimate", 
       x = "Post-hanau dummy")

weights_df_plot

ggsave(weights_df_plot, 
       filename = "./figures/figure_B.9_survey_weights.pdf", 
       height = 8, width = 9, scale = 0.75)



# Figure B.10: TE heterogeneity -------------------------------------------

te_models_data <- fb_2019_2020_models %>% 
  mutate(birth_decade_inter = ifelse(as.numeric(birth_decade) >= 1960, "1960-2000", "1920-1950"), 
         children_inter = ifelse(children == "no children", "no children", "1+ children"), 
         education_inter = ifelse(education == "college", "college or higher", "any high school"), 
         family_status_inter = ifelse(family_status == "married", "married", "single or other"), 
         income_inter = ifelse(income == 10, "4500+", "less than 4500"), 
         occupation_status_inter = ifelse(occupation_status == "unemployed", "unemployed", 
                                          "full/part-time employed"), 
         east = ifelse(east == "east", TRUE, FALSE), 
         religion = forcats::fct_relevel(religion, c("no religion", "protestant", "catholic", "non-christian")))

# LTW

te_models_ltw <- feols(ltw_afd_intention ~ 
                         sw(
                           post_hanau * birth_decade_inter, 
                           post_hanau * east, 
                           post_hanau * children_inter, 
                           post_hanau * education_inter, 
                           post_hanau * family_status_inter, 
                           post_hanau * income_inter, 
                           post_hanau * occupation_status_inter,
                           post_hanau * religion, 
                           post_hanau * sample, 
                           post_hanau * male
                         )
                       
                       | sw0(.[covariates]), 
                       se = "hetero",
                       data = te_models_data %>% 
                         filter(days_new %in% c(-10:9)))


te_models_ltw_df <-  map_dfr(te_models_ltw, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  mutate(weights = "weight2")

te_models_plot <- te_models_ltw_df %>% 
  filter(grepl("post_hanau\\:", term)) %>% 
  mutate(term = gsub("post_hanau\\:", "", term)) %>% 
  mutate(term = fct_reorder(term, estimate)) %>% 
  ggplot(., aes(x = term, y = estimate, color = cov)) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_point(size = 2, position = position_dodge(width = 0.5)) + 
  geom_errorbar(aes(ymin = conf.low, 
                    ymax = conf.high), width = 0, 
                position = position_dodge(width = 0.5))  +
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error,
                    ymax = estimate + 1.67 * std.error), 
                position = position_dodge(width = 0.5), 
                width = 0, size = 0.75) + 
  labs(x = "Post-hanau x ...") +
  scale_x_discrete(labels = c("religioncatholic" = "Catholic (vs. protestant)", 
                              "eastTRUE" = "East (vs. West)", 
                              "children_interno children" = "No children (vs. 1 or more children)", 
                              "birth_decade_inter1960-2000" = "Born after 1960 (vs. born before 1960)", 
                              "education_intercollege or higher" = "College education (vs. high school education",
                              "family_status_intersingle or other" = "Single (vs. married/widowed)",
                              "income_interless than 4500" = "Income less than 4500 EUR\n(vs. more than 4500 EUR)", 
                              "occupation_status_interunemployed" = "Unemployed (vs. employed)", 
                              "religionprotestant" = "Protestant (vs. non-religious)", 
                              "religioncatholic" = "Catholic (vs. non-religious)", 
                              "religionnon-christian" = "Non-Christian (vs. non-religious)", 
                              "samplemobile phone" = "Mobile phone sample\n(vs. landline sample)", 
                              "malemale" = "Male (vs. female)")) +
  coord_flip() +
  theme_bw() + 
  theme(legend.position = "bottom", 
        panel.grid = element_blank()) +
  labs(y = "Coefficient estimate") +
  scale_color_manual("", 
                     values = c( "grey52", "black")) 
# facet_wrap(~rhs, scales = "free_x") 

te_models_plot

ggsave(te_models_plot, 
       filename = "./figures/figure_B.10_TE_heterogeneity.pdf", 
       height = 9, width = 7, scale = 0.7)


# Figure B.11: Covid-19 ---------------------------------------------------


tweets_plot_data <- tweets %>%
  mutate(
    across(c(afd_right_wing:hanau), ~ .x/tweets_total, .names = "{.col}_share"),
    # anti_afd_hashtag_share = anti_afd_hashtag/tweets_total,
    attack = case_when(
      recorded_at_date < as.Date("2019-07-30") ~ "Wolfhagen-Istha",
      recorded_at_date > as.Date("2019-07-30") & recorded_at_date < as.Date("2020-01-01")  ~ "Halle",
      T ~ "Hanau")
  ) %>%
  rowwise() %>%
  mutate(
    date_relative = case_when(
      attack == "Hanau" ~ as.numeric(recorded_at_date - as.Date("2020-02-19")),
      attack == "Halle" ~ as.numeric(recorded_at_date - as.Date("2019-10-09")),
      T ~ as.numeric(recorded_at_date - as.Date("2019-06-16"))
    ),
    attack = factor(attack, levels = c("Hanau", "Halle", "Wolfhagen-Istha"))
  ) %>%
  ungroup() %>%
  mutate(post_attack = case_when(date_relative >= 0 ~ T, T ~ F))



plot_issue_salience <- 
  tweets_plot_data %>%
  select(recorded_at_date, date_relative, hanau_share, covid_share) %>%
  pivot_longer(c(hanau_share, covid_share)) %>%
  filter(recorded_at_date > as.Date("2020-01-01")) %>%
  filter(date_relative %in% -10:10) %>%
  ggplot(data = ., aes(y = value, x = date_relative)) +
  geom_rect(xmin = -5, xmax = 5, ymin = -Inf, ymax = Inf, fill = "grey90") +
  geom_line(aes(linetype = name)) +
  geom_point() +
  scale_linetype_manual("% tweets mentioning", values = c("covid_share" = "dashed", "hanau_share" = "solid"), labels = c("COVID", "Hanau")) +
  annotate(geom = "label", label = "Bandwidth selection\nin main specification", x = -7, y = 0.04) +
  labs(x = "Days before/since attack", y = "Share Tweets") +
  theme_bw() +
  theme(legend.position = "bottom", panel.grid = element_blank()) 

ggsave(plot_issue_salience, 
       filename = "./figures/figure_B.11_covid_19.pdf",
       width = 8, height = 5.31)


# Figure B.12: Social desirability bias -------------------------------

### Turnout in the past
hanau_sdb_mods <- feols(c(voted_ltw_past, voted_btw_past) ~ 
                          post_hanau 
                        | sw0(.[covariates])
                        , 
                        se = "hetero",
                        data = fb_2019_2020_models %>% 
                          filter(days_new %in% c(-5:4)))


tidy_sdb_mods <- map_dfr(hanau_sdb_mods, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau")

turnout_in_past_elections <- tidy_sdb_mods %>% 
  ggplot(., aes(x = term, 
                y = estimate, 
                color = cov, 
                shape = cov))  +
  geom_hline(yintercept = 0, linetype = "dashed") + 
  
  geom_point(size = 2.5, 
             position = position_dodge(width = 0.75)) +
  geom_errorbar(aes(ymin = conf.low, 
                    ymax = conf.high), width = 0, 
                position = position_dodge(width = 0.75))  +
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error,
                    ymax = estimate + 1.67 * std.error), 
                position = position_dodge(width = 0.75), 
                width = 0, size = 0.75) + 
  theme_bw() +
  scale_color_manual("", 
                     values = c("grey52", "black")) +
  scale_shape_discrete("") +
  scale_x_discrete(labels = c("Post-Hanau coefficient", "Post-Hanau coefficient")) + 
  facet_wrap(~lhs,labeller = labeller(lhs = c("btw" = "Voted in last federal elections?", 
                                              "ltw" = "Voted in last state elections?"))) + 
  labs(y = "Treatment effect on\nturnout in last elections", 
       x = "") +
  theme(legend.position = "bottom", 
        panel.grid = element_blank())


turnout_in_past_elections

### AfD vote in the past

past_vote_mod <- feols(c(ltw_afd_past, btw_afd_past) ~ 
                         post_hanau
                       | sw0(.[covariates])
                       , 
                       se = "hetero",
                       data = fb_2019_2020_models %>% 
                         filter(days_new %in% c(-5:4)))



past_vote_mod_df <- map_dfr(past_vote_mod, tidy, conf.int = T, .id = "id") %>% 
  separate(id, into = c("cov", "lhs"), sep = "; ") %>% 
  mutate(cov = ifelse(grepl("1", cov), "no covariates", "covariates"), 
         lhs = ifelse(grepl("btw",lhs), "btw", "ltw")) %>% 
  filter(term == "post_hanau")


past_vote_plot <- past_vote_mod_df %>% 
  ggplot(., aes(x = term, 
                y = estimate, 
                color = cov, 
                shape = cov))  +
  geom_hline(yintercept = 0, linetype = "dashed") + 
  
  geom_point(size = 2.5, 
             position = position_dodge(width = 0.75)) +
  geom_errorbar(aes(ymin = conf.low, 
                    ymax = conf.high), width = 0, 
                position = position_dodge(width = 0.75))  +
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error,
                    ymax = estimate + 1.67 * std.error), 
                position = position_dodge(width = 0.75), 
                width = 0, size = 0.75) + 
  theme_bw() +
  scale_color_manual("", 
                     values = c( "grey52", "black")) +
  scale_shape_discrete("") +
  scale_x_discrete(labels = c("Post-Hanau coefficient", "Post-Hanau coefficient")) + 
  facet_wrap(~lhs,labeller = labeller(lhs = c("btw" = "Voted AfD last federal elections?", 
                                              "ltw" = "Voted AfD last state elections?"))) + 
  
  labs(y = "Treatment effect on\nAfD vote in last elections", 
       x = "") +
  theme(legend.position = "bottom", 
        panel.grid = element_blank())

past_vote_plot



### Full SDB plot

sdb_plot <- (turnout_in_past_elections / past_vote_plot ) + plot_layout(guides = "collect") & theme(legend.position = 'bottom')

sdb_plot

ggsave(sdb_plot, filename = "./figures/figure_B.12_sdb.pdf", 
       height = 7, width = 8, scale = 0.8)



# Figure B.13: Scial desirability non-response --------------------


# Forsa
soc_des_model_fb <- feols(c(is.na(ltw_cdu_intention), 
                            is.na(btw_cdu_intention)) ~ 
                            post_hanau  +
                            .[covariates],
                          se = "hetero",
                          data = fb_2019_2020_models %>% 
                            filter(days_new %in% c(-5:4)))

soc_des_model_fb_df <- soc_des_model_fb %>% 
  map_dfr(tidy, conf.int = T, .id = "id") %>% 
  filter(grepl("hanau", term)) %>% 
  mutate(party = c("State\n elections", 
                   "Federal\nelections"),
         data = "Forsa")



# survey 



mod_na_report_after_treat  <- feols(c(is.na(party_preference_post_1), 
                                      is.na(party_preference_post_2), 
                                      is.na(party_preference_post_3), 
                                      is.na(party_preference_post_4), 
                                      is.na(party_preference_post_5), 
                                      is.na(party_preference_post_6)
) 
~ 
  
  factor(treatvscontrol)  +
  
  .[cov_full_pap],
data = bilendi_survey %>% 
  filter(any_correct_remember_plot_fotos >= 1),
se = "standard")


mod_na_report_after_treat_df <- mod_na_report_after_treat %>% 
  map_dfr(broom::tidy, conf.int = T, .id = "id") %>% 
  filter(grepl("treat", term)) %>% 
  mutate(party = c("CDU/CSU", "Green", "SPD", "FDP", "AfD", "Left")) %>% 
  mutate(data = "Bilendi/\nSurvey experiment") %>% 
  bind_rows(., soc_des_model_fb_df) 


soc_des_coefplot2 <- mod_na_report_after_treat_df %>% 
  ggplot(., aes(x = party, y = estimate)) + 
  geom_point(size = 2) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  # scale_y_continuous(limits = c(-0.02, 0.03)) +
  theme_bw() +
  theme(panel.grid = element_blank()) +
  labs(x = "", y = "Treatment effect on non-response\n in party preference question") +
  facet_wrap(~data, scales = "free_x")

soc_des_coefplot2

ggsave(soc_des_coefplot2, 
       filename = "./figures/figure_B.13_soc_des_nonresponse.pdf", 
       width = 10, height = 5, 
       scale = .7)



# Figure B.14: Attitudes towards minorities -------------------------------


est_data_refugee_survey <- refugee_survey %>%
  select(datum, date_cont, date_num_hanau,
         bik, bl, wo, s1, s2, s3, s4, s9, s10, V2_1_negative, V2_2_negative,
         refugees_all_neg, vote_afd, gewicht) %>%
  mutate(post_hanau = ifelse(date_num_hanau >= 0, 1, 0)) %>%
  relocate(post_hanau, .after = date_num_hanau) %>%
  rename(negative_all = refugees_all_neg) %>%
  mutate(
    
    negative_short_term = V2_1_negative,
    negative_long_term = V2_2_negative,
    
    location_size = bik,
    state = bl,
    west = ifelse(wo == 1, 1, 0),
    birth_decade = 2020 - s2,
    male  = ifelse(s1 == 1, 1, 0),
    income = ifelse(s9 == 99, NA, s9),
    education = s3,
    employment_status = s4,
    sample = s10,
    
    weight = gewicht
    
  ) %>%
  mutate(
    birth_decade = as.character(birth_decade - birth_decade %% 10)
  )



model_spec_long_term <- "negative_long_term ~ post_hanau" 
model_spec_short_term <- "negative_short_term ~ post_hanau" 
covs <- " | location_size + state + west + birth_decade + male + income + education + employment_status + sample"

mod_long_term_survey_1 <- feols(fml = as.formula(model_spec_long_term),
                                se = "hetero",
                                data = est_data_refugee_survey %>%
                                  filter(date_num_hanau %in% -2:21))

mod_long_term_survey_1_covs <- feols(fml = as.formula(paste0(model_spec_long_term, covs)),
                                     se = "hetero",
                                     data = est_data_refugee_survey %>%
                                       filter(date_num_hanau %in% -2:21))

mod_long_term_survey_2 <- feols(fml = as.formula(model_spec_long_term),
                                se = "hetero",
                                data = est_data_refugee_survey %>%
                                  filter(date_num_hanau %in% -20:30))


mod_long_term_survey_2_covs <- feols(fml = as.formula(paste0(model_spec_long_term, covs)),
                                     se = "hetero",
                                     data = est_data_refugee_survey %>%
                                       filter(date_num_hanau %in% -20:30))

mod_short_term_survey_1<- feols(fml = as.formula(model_spec_short_term),
                                se = "hetero",
                                data = est_data_refugee_survey %>%
                                  filter(date_num_hanau %in% -2:21))

mod_short_term_survey_1_covs <- feols(fml = as.formula(paste0(model_spec_short_term, covs)),
                                      se = "hetero",
                                      data = est_data_refugee_survey %>%
                                        filter(date_num_hanau %in% -2:21))

mod_short_term_survey_2 <- feols(fml = as.formula(model_spec_short_term),
                                 se = "hetero",
                                 data = est_data_refugee_survey %>%
                                   filter(date_num_hanau %in% -20:30))

mod_short_term_survey_2_covs <- feols(fml = as.formula(paste0(model_spec_short_term, covs)),
                                      se = "hetero",
                                      data = est_data_refugee_survey %>%
                                        filter(date_num_hanau %in% -20:30))

models <- list(
  mod_long_term_survey_1 = mod_long_term_survey_1,
  mod_long_term_survey_1_covs = mod_long_term_survey_1_covs,
  mod_long_term_survey_2 = mod_long_term_survey_2,
  mod_long_term_survey_2_covs = mod_long_term_survey_2_covs,
  
  mod_short_term_survey_1 = mod_short_term_survey_1,
  mod_short_term_survey_1_covs = mod_short_term_survey_1_covs,
  mod_short_term_survey_2 = mod_short_term_survey_2,
  mod_short_term_survey_2_covs = mod_short_term_survey_2_covs
)




plot_refugee_survey <- refugee_survey %>%
  filter(date_num_hanau %in% -80:60) %>%
  group_by(date_cont, date_num_hanau) %>%
  summarise(neg_long_term = mean(V2_2_negative, na.rm = T),
            neg_short_term = mean(V2_1_negative, na.rm = T),
            .groups = "keep") %>%
  pivot_longer(starts_with("neg")) %>%
  mutate(name = factor(name,
                       levels = c("neg_long_term", "neg_short_term"),
                       labels = c("Negative attitudes (long-term)",
                                  "Negative attitudes (short-term)"))) %>%
  ggplot(data = ., aes(x = date_num_hanau, y = value)) +
  geom_rect(inherit.aes = F, aes(xmin = 24.5, xmax = Inf, ymin = -Inf, ymax = Inf),
            fill = "grey",
            alpha = 0.05) +
  geom_point() +
  geom_line() +
  geom_vline(xintercept = 0, linetype = "dashed") +
  scale_x_continuous(breaks = seq(-60,40,20)) +
  labs(y = "Share respondents", x = "Days before / since attack") +
  theme_bw() +
  theme(panel.grid = element_blank(),
        legend.position = "bottom") +
  facet_wrap(~name, scales = "free_y")

coefplot_refugee_survey <- models %>%
  map_dfr(broom::tidy, conf.int = T, conf.level = 0.95, .id = "name") %>%
  filter(term == "post_hanau") %>%
  mutate(outcome = ifelse(grepl("long_term", name), 
                          "Negative attitudes (long-term)", 
                          "Negative attitudes (short-term)"),
         cov = ifelse(grepl("cov", name), 1, 0),
         window = case_when(
           grepl("1", name) ~ 1,
           grepl("2", name) ~ 2
         )) %>%
  #view()
  ggplot(data = ., aes(x = window, y = estimate, group = cov, color = factor(cov))) +
  geom_point(size = 2.5,
             aes(shape = factor(cov)), 
             position = position_dodge(width = 0.5)) +
  scale_color_manual("", label = c("no covariates", "covariates"),
                     values = c("grey52", "black")) +
  scale_shape_discrete("", label = c("no covariates", "covariates")) +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size = 0.25,
                position = position_dodge(width = 0.5), alpha = 0.9) + 
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error,
                    ymax = estimate + 1.67 * std.error), width = 0, size = 0.75, 
                position = position_dodge(width = 0.5), alpha = 0.9) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_rect(inherit.aes = F, aes(xmin = 1.5, xmax = Inf, ymin = -Inf, ymax = Inf), 
            fill = "grey",
            alpha = 0.1
  ) +
  scale_x_continuous(breaks = c(1, 2)) +
  theme_bw() +
  theme(panel.grid = element_blank(),
        legend.position = "bottom") +
  ylab("Estimate") +
  xlab("Bandwidth window around the cutoff (survey days)") +
  facet_wrap(~outcome)

# Combine and save plot

plot_refugee_survey / coefplot_refugee_survey
combined_plot_refugee_survey <- plot_refugee_survey / coefplot_refugee_survey

ggsave(combined_plot_refugee_survey, 
       filename = "./figures/figure_B.14_refugees.pdf", 
       width = 8, height = 8, scale = 0.8)



# Figure B.15: Rally around the flag --------------------------------------



hanau_ols_other_parties_btw <- feols(c(btw_cdu_intention, 
                                       btw_spd_intention,
                                       btw_green_intention, 
                                       btw_left_intention,
                                       btw_fdp_intention,
                                       btw_afd_intention) ~ 
                                       post_hanau
                                     | sw0(.[covariates]),
                                     se = "hetero",
                                     data = fb_2019_2020_models %>% 
                                       filter(days_new %in% c(-5:4)))

hanau_ols_other_parties_ltw <- feols(c(ltw_cdu_intention, 
                                       ltw_spd_intention,
                                       ltw_green_intention, 
                                       ltw_left_intention,
                                       ltw_fdp_intention,
                                       ltw_afd_intention) ~ 
                                       post_hanau
                                     | sw0(.[covariates]),
                                     se = "hetero",
                                     data = fb_2019_2020_models %>% 
                                       filter(days_new %in% c(-5:4)))



other_parties_models_btw <- as.list(hanau_ols_other_parties_btw) %>% 
  map_dfr(tidy, conf.int = T, .id = "id") %>% 
  separate(id, sep = "; ", into = c("rhs", "lhs")) %>% 
  mutate(cov = ifelse(grepl("1", rhs), "no covariates", "covariates")) %>% 
  mutate(election_type = str_extract(lhs, "btw|ltw")) %>% 
  mutate(lhs = str_extract(lhs, "cdu|spd|green|left|fdp|afd")) %>% 
  filter(term == "post_hanau")

other_parties_models_ltw <- as.list(hanau_ols_other_parties_ltw) %>% 
  map_dfr(tidy, conf.int = T, .id = "id") %>% 
  separate(id, sep = "; ", into = c("rhs", "lhs")) %>% 
  mutate(cov = ifelse(grepl("1", rhs), "no covariates", "covariates")) %>% 
  mutate(election_type = str_extract(lhs, "btw|ltw")) %>% 
  mutate(lhs = str_extract(lhs, "cdu|spd|green|left|fdp|afd")) %>% 
  filter(term == "post_hanau")

other_parties_models <- bind_rows(
  other_parties_models_ltw, 
  other_parties_models_btw
)


coefplot_other_parties <- other_parties_models %>% 
  ggplot(., aes(x = term, y = estimate, color = lhs, group = cov)) + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  
  
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size = 0.25, 
                position = position_dodge(width = 0.5), alpha = 0.9) + 
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error, 
                    ymax = estimate + 1.67 * std.error), width = 0, size = 0.75, 
                position = position_dodge(width = 0.5), alpha = 0.9) + 
  geom_point(size = 2.5,
             aes(shape = cov), 
             position = position_dodge(width = 0.5)) + 
  scale_color_manual("", values = c(afd = "#0489DB", 
                                    spd = "#E3000F", 
                                    green = "#1AA037", 
                                    fdp = "#ffd600", 
                                    left = "#b61c3e",
                                    cdu = "#000000"), guide = "none") +

  scale_shape_discrete("", label = c("covariates", "no covariates")) +

  scale_x_discrete(labels = c("Post-Hanau Dummy")) +
  theme_bw() + 
  theme(panel.grid = element_blank(), 
        legend.position = "bottom", 
        axis.text.x = element_text(size = 7.5)) +
  labs(x = "", y= "Coefficient estimate") +
  facet_grid(lhs ~ election_type, 
             labeller = labeller(election_type = c("btw" = "Federal elections", 
                                                   "ltw" = "State elections"), 
                                 lhs = c("cdu" = "CDU", 
                                         "spd" = "SPD", 
                                         "green" = "Greens", 
                                         "left" = "Linke (left)", 
                                         "fdp" = "FDP", 
                                         "afd" = "AfD")))

coefplot_other_parties

ggsave(coefplot_other_parties, 
       filename = "./figures/figure_B.15_rally.pdf", 
       width = 7, height = 11, scale = 0.8)



# * Survey experiment * -----------------------------------------------------



# Figure B.19: Survey exp. balance ----------------------------------------



# need to create dummies for education and political interest and state
bilendi_survey <- bilendi_survey %>% 
  fastDummies::dummy_cols(select_columns = c("education")) %>% 
  fastDummies::dummy_cols(select_columns = c("state"))


covariates_balance <- bilendi_survey %>%
  select(starts_with("party_preference_pre"), 
         starts_with("afd_antise"), 
         starts_with("afd_antimm"),
         starts_with("male"),
         starts_with("age"),
         political_interest,
         starts_with("education_"),
         starts_with("state_")) %>%
  names()



cov_labels <- c("party_preference_pre_1" = "CDU/CSU", 
                "party_preference_pre_2" = "Grüne", 
                "party_preference_pre_3" = "SPD", 
                "party_preference_pre_4" = "FDP", 
                "party_preference_pre_5" = "AfD", 
                "party_preference_pre_6" = "Linke", 
                "political_interest" = "Political interest", 
                "education_1" =  "Without high school", 
                "education_2" = "Volks- / Hauptschule", 
                "education_3" = "Polytechnische Oberschule",
                "education_4" = "Mittlere Reife",
                "education_5" = "Hochschulreife / Abitur",
                "education_6" = "Currently in school",
                "education_7" = "Other high school degree", 
                "male" = "Male", 
                "age" = "Age", 
                "state_1" = "Baden Württemberg",
                "state_2" = "Bayern",
                "state_3" = "Berlin",
                "state_4" = "Brandenburg", 
                "state_5" = "Bremen", 
                "state_6" = "Hamburg", 
                "state_7" = "Hessen", 
                "state_8" = "Mecklenburg-Vorpommern", 
                "state_9" = "Niedersachsen", 
                "state_10" = "Nordrhein Westfalen", 
                "state_11" = "Rheinland-Pfalz", 
                "state_12" = "Saarland", 
                "state_13" = "Sachsen", 
                "state_14" = "Sachsen-Anhalt", 
                "state_15" = "Schleswig-Holstein", 
                "state_16" = "Thüringen", 
                "afd_antisemitic_1" = "CDU/CSU", 
                "afd_antisemitic_2" = "Grüne", 
                "afd_antisemitic_3" = "SPD", 
                "afd_antisemitic_4" = "FDP", 
                "afd_antisemitic_5" = "AfD", 
                "afd_antisemitic_6" = "Linke", 
                "afd_antimmigration_1" = "CDU/CSU", 
                "afd_antimmigration_2" = "Grüne", 
                "afd_antimmigration_3" = "SPD", 
                "afd_antimmigration_4" = "FDP", 
                "afd_antimmigration_5" = "AfD", 
                "afd_antimmigration_6" = "Linke"
)


## balance models

lm_testdata_balance <- 
  feols(.[covariates_balance] ~ 
          factor(treatment),
        data =bilendi_survey %>% 
          filter(any_correct_remember_plot_fotos >= 1) %>% 
          # standardize covariates
          mutate(across(all_of(c(covariates_balance)), 
                        function(x) as.numeric(scale(x))
          )))



## balance coefplot 

coefplot_balance <- lm_testdata_balance %>%
  map_dfr(broom::tidy, conf.int = T, .id = "id", conf.level = 0.95) %>%
  filter(grepl("treat", term)) %>%
  mutate(id = gsub("lhs: ", "", id)) %>% 
  mutate(id = fct_reorder(id, estimate)) %>% 
  mutate(type = case_when(grepl("education", id) ~ "Education", 
                          grepl("male|age|political", id) ~ "Personal characteristics", 
                          grepl("party", id) ~ "Party preference", 
                          grepl("antimm", id) ~ "Perception of party\nbeing anti-immigration", 
                          grepl("antisem", id) ~ "Perception of party\nbeing antisemitic", 
                          grepl("state", id) ~ "State")) %>% 
  ggplot(., aes(x = id, y = estimate, color = term, group = term)) + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_point(size = 3, position = position_dodge(width = 0.75), 
             aes(shape = term)) +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, size = 0.25, 
                position = position_dodge(width = 0.75), alpha = 0.9) + 
  geom_errorbar(aes(ymin = estimate - 1.67 * std.error, 
                    ymax = estimate + 1.67 * std.error), width = 0, size = 0.75, 
                position = position_dodge(width = 0.75), alpha = 0.9) + 
  scale_x_discrete(labels = cov_labels) +
  
  coord_flip() +
  labs(y = "\nTreatment group coefficients",
       x = "Pre-treatment outcome") +
  theme_bw() +
  facet_wrap(type ~ ., scales = "free_y") +
  theme(legend.position = "bottom", 
        panel.grid = element_blank()) +
  scale_color_manual("", values = c("grey60", "black"),  
                     labels = c("factor(treatment)2" = "Treatment 1: right-wing attack (no media backlash)",
                                "factor(treatment)3" = "Treatment 2: right-wing attack (with media backlash)")) +
  scale_shape_discrete("", labels = c("factor(treatment)2" = "Treatment 1: right-wing attack (no media backlash)",
                                      "factor(treatment)3" = "Treatment 2: right-wing attack (with media backlash)")) 


print(coefplot_balance)


ggsave(coefplot_balance, 
       filename = "./figures/figure_B.19_survey_exp_balance.pdf", 
       width = 14, height = 15, scale = 0.7)


# Figure B.20: Separate AfD outcomes --------------------------------------





te_pap_1_attention <- feols(c(party_preference_post_5, party_programme_5) ~ 
                              
                              factor(treatvscontrol)  +
                              
                              # full pap covariates
                              sw0(.[cov_full_pap]),
                            data =  bilendi_survey %>% 
                              filter(any_correct_remember_plot_fotos >= 1),
                            se = "standard")

te_pap_2_attention <- feols(c(party_preference_post_5, party_programme_5) ~ 
                              
                              factor(treatment)  +
                              
                              # full pap covariates
                              sw0(.[cov_full_pap]),
                            data = bilendi_survey %>% 
                              filter(any_correct_remember_plot_fotos >= 1),
                            se = "standard")





pap_models <- bind_rows(
  te_pap_1_attention %>% map_dfr(broom::tidy, conf.int = T, .id = "id"),
  te_pap_2_attention %>% map_dfr(broom::tidy, conf.int = T, .id = "id") 
) %>% 
  mutate(outcome = ifelse(grepl("lhs\\: party_prefere", id), "Outcome 1: AfD party preference", "Outcome 2: AfD programmatic agreement")) %>% 
  mutate(Covariates = ifelse(grepl("\\+", id), "with covariates", "no covariates")) %>% 
  filter(grepl("treat", term)) 

main_coefficient_plot_sep_outcomes <- pap_models %>% 

  ggplot(., aes(x = term, y = estimate, 
                group = Covariates, color = Covariates)) +
  geom_vline(xintercept = 2.5) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25, 
                position = position_dodge(width = .5)) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7, 
                position = position_dodge(width = .5)) +
  geom_point(size = 3,# aes(shape = term), 
             # color = "black", 
             position = position_dodge(width = .5)) + 
  scale_x_discrete(labels = c("factor(treatvscontrol)treatment" = "Pooled treatment", 
                              "factor(treatment)2" = "Treatment group 1\n(no media backlash)", 
                              "factor(treatment)3" = "Treatment group 2\n(with media backlash)")) +
  facet_wrap(~outcome) +
  theme_bw() + 
  scale_color_manual("", values = c("grey60", "black")) + 
  
  theme(legend.position = "bottom", 
        panel.grid = element_blank(),
        axis.text.x = element_text(size = 8), 
        strip.text = element_markdown()) +
  labs(y = "Treatment effect estimate\nof right-wing attack", x = "Treatment group specification")


main_coefficient_plot_sep_outcomes

ggsave(main_coefficient_plot_sep_outcomes, 
       filename = "./figures/figure_B.20_sep_outcomes.pdf",
       width = 13.5, height = 5.5, scale = 0.7)




# Figure B.21: Missingness problems -------------------------------------------

cov_full_pap_missingness  <- c("male",
                   "age",
                   "education",
                   "political_interest",
                   
                   "party_preference_pre_1", 
                   "party_preference_pre_2", 
                   "party_preference_pre_3", 
                   "party_preference_pre_4", 
                   "party_preference_pre_5", 
                   "party_preference_pre_6", 
                   
                   "afd_antimmigration_1", 
                   "afd_antimmigration_2", 
                   "afd_antimmigration_3", 
                   "afd_antimmigration_4", 
                   "afd_antimmigration_5", 
                   "afd_antimmigration_6", 
                   
                   "afd_antisemitic_1", 
                   "afd_antisemitic_2", 
                   "afd_antisemitic_3", 
                   "afd_antisemitic_4", 
                   "afd_antisemitic_5", 
                   "afd_antisemitic_6")



cov_labels <- c("party_preference_pre_1" = "Party preference: CDU/CSU", 
                "party_preference_pre_2" = "Party preference: Grüne", 
                "party_preference_pre_3" = "Party preference: SPD", 
                "party_preference_pre_4" = "Party preference: FDP", 
                "party_preference_pre_5" = "Party preference: AfD", 
                "party_preference_pre_6" = "Party preference: Linke", 
                "political_interest" = "Political interest", 
                "education_1" =  "Without high school", 
                "education_2" = "Volks- / Hauptschule", 
                "education_3" = "Polytechnische Oberschule",
                "education_4" = "Mittlere Reife",
                "education_5" = "Hochschulreife / Abitur",
                "education_6" = "Currently in school",
                "education_7" = "Other high school degree", 
                "male" = "Male", 
                "age" = "Age", 
                "education" = "Education", 
                "state_1" = "Baden Württemberg",
                "state_2" = "Bayern",
                "state_3" = "Berlin",
                "state_4" = "Brandenburg", 
                "state_5" = "Bremen", 
                "state_6" = "Hamburg", 
                "state_7" = "Hessen", 
                "state_8" = "Mecklenburg-Vorpommern", 
                "state_9" = "Niedersachsen", 
                "state_10" = "Nordrhein Westfalen", 
                "state_11" = "Rheinland-Pfalz", 
                "state_12" = "Saarland", 
                "state_13" = "Sachsen", 
                "state_14" = "Sachsen-Anhalt", 
                "state_15" = "Schleswig-Holstein", 
                "state_16" = "Thüringen", 
                "afd_antisemitic_1" = "Anti-Semitism: CDU/CSU", 
                "afd_antisemitic_2" = "Anti-Semitism: Grüne", 
                "afd_antisemitic_3" = "Anti-Semitism: SPD", 
                "afd_antisemitic_4" = "Anti-Semitism: FDP", 
                "afd_antisemitic_5" = "Anti-Semitism: AfD", 
                "afd_antisemitic_6" = "Anti-Semitism: Linke", 
                "afd_antimmigration_1" = "Anti-Refugee: CDU/CSU", 
                "afd_antimmigration_2" = "Anti-Refugee: Grüne", 
                "afd_antimmigration_3" = "Anti-Refugee: SPD", 
                "afd_antimmigration_4" = "Anti-Refugee: FDP", 
                "afd_antimmigration_5" = "Anti-Refugee: AfD", 
                "afd_antimmigration_6" = "Anti-Refugee: Linke"
)




missingness_analysis <- bilendi_survey %>% 
  ungroup() %>% 
  summarise(across(cov_full_pap_missingness, \(x) sum(is.na(x))), 
            n = n()) %>% 
  pivot_longer(cols = -n) %>% 
  mutate(name = fct_reorder(name, value), 
         missing_share = value/n)  %>% 
  mutate(problematic_covariate = ifelse(grepl("antisem|antimm", name), TRUE, FALSE)) %>% 
  group_by(problematic_covariate) %>% 
  mutate(avg_missing= mean(missing_share)) %>% 
  ggplot(., aes(x = name, y = missing_share)) + 
  geom_col() +
  # geom_linerange(aes(y = avg_missing, xmin = 0, xmax = 11)) +
  coord_flip() +
  labs(x = "PAP specified covariate") +
  facet_wrap(~problematic_covariate, scales = "free_y", 
             labeller = labeller(problematic_covariate = c("TRUE" = "Excluded covariates",
                                                           "FALSE" = "Included covariates"))) + 
  scale_x_discrete(labels = cov_labels) +
  theme_bw() + 
  theme(panel.grid = element_blank()) +
  labs(y = "Share of missing values (\"don't know\") in variables")


# consequences
missingess_bilendi <- bilendi_survey %>% 
  mutate(listwise_deleted = !complete.cases(bilendi_survey %>% select(cov_full_pap[grepl("antimm|antisem", cov_full_pap)]))) %>% 
  group_by(listwise_deleted) %>% 
  summarise(mean_polit_interest = mean(political_interest, na.rm = T), 
            mean_age = mean(age ,na.rm = T), 
            median_education = median(education, na.rm = T), 
            mean_afd = mean(party_preference_pre_5, na.rm = T), 
            mean_gruene = mean(party_preference_pre_2, na.rm = T), 
            mean_linke = mean(party_preference_pre_6, na.rm = T), 
            mean_cdu = mean(party_preference_pre_1, na.rm = T), 
            mean_fdp = mean(party_preference_pre_4, na.rm = T), 
            mean_spd= mean(party_preference_pre_3, na.rm = T))


missingness_analysis

ggsave(missingness_analysis, 
       filename = "./figures/figure_B.21_missingness_descriptive.pdf", 
       width = 10, height = 5, scale = 0.7)


# Figure B.22: Missingness robustness ------------------------------------



cov_full_pap_missingness  <- c("male",
                   "age",
                   "factor(education)",
                   "political_interest",
                   
                   "party_preference_pre_1", 
                   "party_preference_pre_2", 
                   "party_preference_pre_3", 
                   "party_preference_pre_4", 
                   "party_preference_pre_5", 
                   "party_preference_pre_6",
                   
                   "afd_antimmigration_1",
                   "afd_antimmigration_2",
                   "afd_antimmigration_3",
                   "afd_antimmigration_4",
                   "afd_antimmigration_5",
                   "afd_antimmigration_6",
                   
                   "afd_antisemitic_1",
                   "afd_antisemitic_2",
                   "afd_antisemitic_3",
                   "afd_antisemitic_4",
                   "afd_antisemitic_5",
                   "afd_antisemitic_6"
)



cov_limited_pap  <- c("male",
                      "age",
                      "factor(education)",
                      "political_interest",
                      
                      "party_preference_pre_1", 
                      "party_preference_pre_2", 
                      "party_preference_pre_3", 
                      "party_preference_pre_4", 
                      "party_preference_pre_5", 
                      "party_preference_pre_6"
                      
                      
)




te_pap_1_attention <- feols(c(afd_pref_post) ~ 
                              
                              factor(treatvscontrol)  +
                              
                              # full pap covariates
                              sw(.[cov_limited_pap], 
                                  .[cov_full_pap_missingness])
                            ,
                            data =  bilendi_survey %>% 
                              filter(any_correct_remember_plot_fotos >= 1),
                            se = "standard")

te_pap_2_attention <- feols(c( afd_pref_post) ~ 
                              
                              factor(treatment)  +
                              
                              # full pap covariates
                              sw(.[cov_limited_pap], 
                                  .[cov_full_pap_missingness])
                            ,
                            data = bilendi_survey %>% 
                              filter(any_correct_remember_plot_fotos >= 1),
                            se = "standard")


pap_models <- bind_rows(
  te_pap_1_attention %>% map_dfr(broom::tidy, conf.int = T, .id = "id") ,
  te_pap_2_attention %>% map_dfr(broom::tidy, conf.int = T, .id = "id") 
) %>% 
  mutate(Covariates = ifelse(grepl("antise", id), "covariates incl. refugee + antisemitism variables", "covariates excl. refugee + antisemitism variables")) %>% 
  filter(grepl("treat", term)) 

main_coefficient_plot <- pap_models %>% 

  ggplot(., aes(x = term, y = estimate, 
                group = Covariates, color = Covariates)) +
  geom_vline(xintercept = 2.5) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25, 
                position = position_dodge(width = .5)) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7, 
                position = position_dodge(width = .5)) +
  geom_point(size = 3,# aes(shape = term), 
             # color = "black", 
             position = position_dodge(width = .5)) + 
  scale_x_discrete(labels = c("factor(treatvscontrol)treatment" = "Pooled treatment", 
                              "factor(treatment)2" = "Treatment group 1\n(no media backlash)", 
                              "factor(treatment)3" = "Treatment group 2\n(with media backlash)")) +
  theme_bw() + 
  scale_color_manual("", values = c("grey60", "black")) + 
  
  theme(legend.position = "bottom", 
        panel.grid = element_blank(),
        axis.text.x = element_text(size = 8), 
        strip.text = element_markdown()) +
  labs(y = "Treatment effect estimate\nof right-wing attack", x = "Treatment group specification")


main_coefficient_plot

ggsave(main_coefficient_plot, 
       filename = "./figures/figure_B.22_missingness_robust.pdf", 
       width = 10.5, height = 5.5, scale = 0.7)


# Figure B.23: Mechanism analysis -----------------------------------------




manip_mod <- feols(c(public_opinion, 
                     violence_problem) ~ 
                     
                     factor(treatment) +
                     
                     .[cov_full_pap],
                   data = bilendi_survey %>% 
                     mutate(public_opinion = as.numeric(scale(public_opinion)),
                            violence_problem = as.numeric(scale(violence_problem))) %>%
                     filter(any_correct_remember_plot_fotos >= 1), 
                   se = "standard")



mechanism_mod <- feols(c(afd_violent_5 , 
                         afd_extreme_5) ~ 
                         
                         factor(treatment) +
                         
                         .[cov_full_pap],
                       data = bilendi_survey %>% 
                         mutate(afd_violent_5 = as.numeric(scale(afd_violent_5)),
                                afd_extreme_5 = as.numeric(scale(afd_extreme_5))) %>%
                         filter(any_correct_remember_plot_fotos >= 1),
                       se = "standard")




alt_mechanism_mod <- feols(c(social_desirability, 
                             migration_sentiment) ~ 
                             
                             factor(treatment) +
                             
                             # socio-economi covariates
                             .[cov_full_pap],
                           data = bilendi_survey %>% 
                             mutate(social_desirability = as.numeric(scale(social_desirability)),
                                    migration_sentiment = as.numeric(scale(migration_sentiment))) %>%
                             filter(any_correct_remember_plot_fotos >= 1), 
                           se = "standard")



## label survey items 
mech_models_df <- bind_rows(
  manip_mod %>% map_dfr(broom::tidy, conf.int = T, .id = "id") %>% mutate(mechanism = "Manipulation"),
  mechanism_mod %>% map_dfr(broom::tidy, conf.int = T, .id = "id") %>% mutate(mechanism = "Mechanism"),
  alt_mechanism_mod %>% map_dfr(broom::tidy, conf.int = T, .id = "id") %>% mutate(mechanism = "Alternative\nmechanism")
)

labels_dv <- c("public_opinion" = "Many people blame AfD for violence: yes (1-7)", 
               "violence_problem" = "Right-wing terror is a core problem in Germany: yes (1-7)", 
               "afd_extreme_5" = "Extremist thought is widespread in the AfD: 1 (yes) - 4 (no)", 
               "afd_violent_5" = "The AfD increases the risk of conflict and violence in Germany: yes (1-7)",
               "social_desirability" = "I've never said anyting that would hurt migrants: yes (1-7)")

labels_dv_std <- c("public_opinion" = "...many people blame the AfD for violence ", #(public_opinion)", 
                   "violence_problem" = "...right-wing terror is a core problem in Germany ", #(violence_problem)", 
                   "afd_extreme_5" = "...extremist thought is widespread in the AfD ", #(afd_extreme_5)", 
                   "afd_violent_5" = "...the AfD increases the risk of conflict and violence in Germany ", #(afd_violent_5)",
                   "migration_sentiment" = "...I think the impact of refugees in Germany has been positive ", #(migration_sentiment)",
                   "social_desirability" = "...I've never said anyting that would hurt migrants ", #(social_desirability)", 
                   "afd_pref_post" = "AfD support", 
                   "v_93" = "...I am angry that many blame the AfD for the crimes of single perpetrators ", #(v_93)", 
                   "v_94" = "...the more the AfD is unjustifiably blamed in public, the more I support the AfD ") #(v_94)")


## build final plot

mech_plot <- mech_models_df %>% 
  filter(grepl("treatment", term)) %>% 
  mutate(mechanism = fct_inorder(mechanism)) %>% 
  mutate(id = gsub("lhs: ", "", id)) %>% 
  ggplot(., aes(x = id, 
                y = estimate, color = term, fill = term)) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, size = 0.25, 
                position = position_dodge(width = .5)) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, size = 0.7, 
                position = position_dodge(width = .5)) +
  geom_point(size = 3,# aes(shape = term), 
             position = position_dodge(width = .5)) + 
  scale_x_discrete(labels = function(x) str_wrap(str_replace_all(x, labels_dv_std), 20)) +
  scale_color_manual("", values = c("grey60", "black"),  
                     labels = c("factor(treatment)2" = "Treatment 1: right-wing attack (no public backlash)",
                                "factor(treatment)3" = "Treatment 2: right-wing attack (with public backlash)")) +
  scale_fill_manual("",  values = c("grey60", "black"),  
                    labels = c("factor(treatment)2" = "Treatment 1: right-wing attack (no public backlash)",
                               "factor(treatment)3" = "Treatment 2: right-wing attack (with public backlash)")) +
  scale_shape_manual("", 
                     labels = c("factor(treatment)2" = "Treatment 1: right-wing attack (no public backlash)",
                                "factor(treatment)3" = "Treatment 2: right-wing attack (with public backlash)"), 
                     values = c(21, 24)) +
  labs(x = "\nAgreement with survey item stating that...", y = "Treatment effect coefficient") + 
  facet_wrap(~mechanism, scales = "free_x") +
  theme_bw() +
  theme(legend.position = "bottom", 
        panel.grid = element_blank(), 
        strip.text = element_text(size = 12), 
        axis.text.x = element_text(size = 9)) 

mech_plot

ggsave(mech_plot, filename = "./figures/figure_B.23_mechanisms.pdf", 
       width = 12, height = 8, scale = 0.7)


# Figure B.24: Effect size comparison ----------------------------------------


# estimate survey experiment effects with one treatment group vs. control for different
# outcome dummy cutoffs



models <- list()
counter <- 1

for(cutoff in 1:6) {
  
  
  comp_effect_size_model_se <- feols(
    afd_party_post_cutoff  ~ 
      
      I(treatment != 1) +
      
      .[cov_full_pap],
    data = bilendi_survey %>% 
      mutate(afd_party_post_cutoff = ifelse(afd_party_post > cutoff & !is.na(afd_party_post), T, F)) %>% 
      filter(any_correct_remember_plot_fotos >= 1),
    se = "standard")
  
  models[[counter]] <- broom::tidy(
    comp_effect_size_model_se, 
    conf.int = T, 
    .id = "id"
  ) %>% mutate(cutoff = cutoff, 
               data = "Survey Experiment")
  counter <- counter + 1
}


models_effect_size_out <- map_dfr(models, as_tibble)


## this is the Forsabus result effect size in comparison
comp_effect_size_model_fb <- feols(c(btw_afd_intention) ~ 
                                     post_hanau 
                                   | .[covariates] , 
                                   se = "hetero",
                                   # weights  = ~weight2,
                                   data = fb_2019_2020_models %>% 
                                     filter(days_new %in% c(-5:4)))

comp_effect_size_model_fb <- broom::tidy(comp_effect_size_model_fb, conf.int = T, .id = "id") %>% 
  mutate(data = "Forsa Bus", 
         cutoff = 8)

models_effect_size_out <- models_effect_size_out %>% 
  filter(grepl("treat", term)) %>% 
  bind_rows(., comp_effect_size_model_fb) %>% 
  group_by(data) %>% 
  mutate(mean_effect = mean(estimate), 
         mean_effect = ifelse(data == "Forsa Bus", NA, mean_effect))


comp_effect_size_coefplot <-   models_effect_size_out %>% 
  ggplot(., aes(x = factor(cutoff), 
                color = data, 
                y = estimate)) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_point(size = 2) + 
  geom_linerange(aes(ymin = conf.low, ymax = conf.high), 
                 linewidth = 0.25) +
  geom_linerange(aes(ymin = estimate - 1.645 * std.error, 
                     ymax = estimate + 1.645 * std.error), 
                 linewidth = 0.7) +
  geom_vline(xintercept = 6.5) +
  
  # mean effect size
  geom_linerange(aes(y = mean_effect, xmin = 0.75, xmax = 6.25), 
                 color = "grey40") + 
  geom_label(data = tibble(cutoff = 3,
                           estimate = -0.012,
                           data = "Survey Experiment",
                           label = "Mean effect size: -0.016"),
             aes(label = label),
             fill = "grey60",
             color = "black", 
             alpha = 0.7) +
  
  
  scale_x_discrete(labels = c(1:6, "Forsa Bus\nreference")) +
  theme_bw() + 
  theme(legend.position = "none", 
        panel.grid = element_blank()) +
  scale_color_manual("Data", 
                     values = c( "black", "grey60")) +
  labs(y = "Treatment effect estimate", 
       x = "Cutoff value (x > cutoff) for binary coding of 7-point Likert scale of survey item x:\n\"How likely is it that you will ever vote for the AfD?\"\n(x = 1: not likely at all; x = 7: very likely)")


comp_effect_size_coefplot

ggsave(comp_effect_size_coefplot, 
       filename = "./figures/figure_B.24_effect_size_comparison.pdf", 
       width = 9, height = 5, 
       scale = .7)



# Figure B.25: HTE by party support ---------------------------------------


party_pref_cutoff <- 2

bilendi_survey <- bilendi_survey %>% 
  mutate(treatgroup = ifelse(treatvscontrol == "treatment", 1, 0), 
         cdu_core = ifelse(party_preference_pre_1 >= party_pref_cutoff, 1, 0), 
         gruene_core = ifelse(party_preference_pre_2 >= party_pref_cutoff, 1, 0), 
         spd_core = ifelse(party_preference_pre_3 >= party_pref_cutoff, 1, 0), 
         fdp_core = ifelse(party_preference_pre_4 >= party_pref_cutoff, 1, 0), 
         afd_core = ifelse(party_preference_pre_5 >= party_pref_cutoff, 1, 0), 
         linke_core = ifelse(party_preference_pre_6 >= party_pref_cutoff, 1, 0)
  )


hte_pap_1_attention_pre_pref <- feols(c(afd_pref_post) ~ 
                                        
                                        sw(
                                          treatgroup * cdu_core  +
                                            .[cov_full_pap], 
                                          treatgroup * gruene_core  +
                                            .[cov_full_pap], 
                                          treatgroup * spd_core  +
                                            .[cov_full_pap], 
                                          treatgroup * fdp_core  +
                                            .[cov_full_pap], 
                                          treatgroup * afd_core +
                                            .[cov_full_pap], 
                                          treatgroup * linke_core  +
                                            .[cov_full_pap]
                                        ),
                                      data =  bilendi_survey %>% 
                                        filter(any_correct_remember_plot_fotos >= 1),
                                      se = "standard")

coef_map <- c("treatgroup" = "Treatment", 
              "cdu_core" = "CDU",
              "treatgroup:cdu_core" = "Treatment x CDU",
              
              "gruene_core" = "Grüne",
              "treatgroup:gruene_core" = "Treatment x Grüne",
              
              "spd_core" = "SPD",
              "treatgroup:spd_core" = "Treatment x SPD",
              
              "fdp_core" = "FDP",
              "treatgroup:fdp_core" = "Treatment x FDP",
              
              "afd_core" = "AfD",
              "treatgroup:afd_core" = "Treatment x AfD",
              
              
              "linke_core" = "Linke",
              "treatgroup:linke_core" = "Treatment x Linke")

names(hte_pap_1_attention_pre_pref) <- 1:6


# plot marginal effects

me_hte_df <- bind_rows(
  avg_comparisons(hte_pap_1_attention_pre_pref[[1]], variables = "treatgroup", by = c("cdu_core")) %>% 
    tibble() %>% 
    rename(core_voter = cdu_core) %>% 
    mutate(party = "CDU"), 
  avg_comparisons(hte_pap_1_attention_pre_pref[[2]], variables = "treatgroup", by = c("gruene_core")) %>% 
    tibble() %>% 
    rename(core_voter = gruene_core) %>% 
    mutate(party = "Gruene"), 
  avg_comparisons(hte_pap_1_attention_pre_pref[[3]], variables = "treatgroup", by = c("spd_core")) %>% 
    tibble() %>% 
    rename(core_voter = spd_core) %>% 
    mutate(party = "SPD"), 
  avg_comparisons(hte_pap_1_attention_pre_pref[[4]], variables = "treatgroup", by = c("fdp_core")) %>% 
    tibble() %>% 
    rename(core_voter = fdp_core) %>% 
    mutate(party = "FDP"), 
  avg_comparisons(hte_pap_1_attention_pre_pref[[5]], variables = "treatgroup", by = c("afd_core")) %>% 
    tibble() %>% 
    rename(core_voter = afd_core) %>% 
    mutate(party = "AfD"), 
  avg_comparisons(hte_pap_1_attention_pre_pref[[6]], variables = "treatgroup", by = c("linke_core")) %>% 
    tibble() %>% 
    rename(core_voter = linke_core) %>% 
    mutate(party = "Linke") 
)


me_hte_coefplot <- me_hte_df %>% 
  
  mutate(party = fct_reorder(party, estimate)) %>% 
  filter(core_voter == 1) %>% 
  ggplot(., aes(x = party, y = estimate)) + 
  geom_point(size = 1.5, 
             position = position_dodge(width = 0.5)) + 
  geom_linerange(aes(ymin = conf.low, ymax = conf.high), 
                 linewidth = 0.25) +
  geom_linerange(aes(ymin = estimate - 1.645 * std.error, 
                     ymax = estimate + 1.645 * std.error), 
                 linewidth = 0.7) +
  geom_hline(yintercept = 0, linetype = "dashed") + 

  scale_color_manual("", values = c("grey", "black"), 
                     labels = c("Control", "Treatment")) +
  labs(x = "\nTreatment effect for core supporters of party ...", 
       y = "Marginal effect of\n post-treatment AfD support") +
  theme_bw() + 
  theme(legend.position = "bottom", 
        panel.grid = element_blank())

me_hte_coefplot

ggsave(me_hte_coefplot, 
       filename = "./figures/figure_B.25_hte_party_support.pdf", 
       width = 10, height = 6.5, scale = 0.7)




# Figure B.26: Comparison Forsabus/Bilendi --------------------------------

forsa_comp <- fb_2019_2020_models %>% 
  filter(days_new %in% c(-5:4)) %>%
  mutate(education = demo9) %>% 
  mutate(education = case_when(education == 1 ~ "No high school", 
                               education == 2 ~ "Hauptschule", 
                               education %in% 3:4 ~ "Realschule",
                               education %in% 5:7 ~ "Abitur/\nFachhochschulreife", 
                               TRUE ~ NA)
  ) %>% 
  mutate(gebj = 2020 - gebj) %>% 
  mutate(age_cat = case_when(gebj %in% 18:25 ~ "18-25", 
                             gebj %in% 26:35 ~ "26-25", 
                             gebj %in% 36:45 ~ "36-45", 
                             gebj %in% 46:55 ~ "46-55", 
                             gebj %in% 56:65 ~ "56-65",
                             gebj > 65 ~ "66+", 
                             TRUE ~ NA
  )) 


covariates_fb <- c(
  "male",
  "bland", 
  "age_cat", 
  "education"
  
)

forsa_comp <- forsa_comp %>% 
  mutate(across(all_of(covariates_fb), \(x) sjlabelled::as_label(x))) %>% 
  select(all_of(covariates_fb))




balance <- function(x, df = NULL) {
  
  
  temp_df <- df %>% 
    group_by(across(all_of(x)))  %>% 
    summarise(n = n()) %>% 
    ungroup() %>% 
    mutate(n_sum = sum(n)) %>% 
    mutate(covariate = x)
  
  names(temp_df)[1] <- "cov_value"
  
  
  temp_df <- temp_df %>% 
    mutate(share = n / n_sum) %>% 
    group_by(cov_value) %>%  
    mutate(upper_ci = share + 1.96 * sqrt(share * (1- share) / n_sum),
           lower_ci = share - 1.96 * sqrt(share * (1- share) / n_sum)) %>% 
    select(-c(n, n_sum))
  
  
  
  temp_df 
}



fb_comp_profile <- map_dfr(covariates_fb, \(x) balance(x, forsa_comp)) %>% 
  filter(!is.na(cov_value)) %>% 
  mutate(data = "Hanau analysis (Forsa-Bus)")



## bilendi


bilendi_comp <- bilendi_survey %>% 
  mutate(education = case_when(education == 1 ~ "No high school", 
                               education == 2 ~ "Hauptschule", 
                               education %in% 3:4 ~ "Realschule",
                               education %in% 5:6 ~ "Abitur/\nFachhochschulreife", 
                               TRUE ~ NA)
  ) %>%
  mutate(age_cat = case_when(age %in% 18:25 ~ "18-25", 
                             age %in% 26:35 ~ "26-25", 
                             age %in% 36:45 ~ "36-45", 
                             age %in% 46:55 ~ "46-55", 
                             age %in% 56:65 ~ "56-65",
                             age > 65 ~ "66+", 
                             TRUE ~ NA
  )) %>% 
  rename(bland = state) %>% 
  
  mutate(male = ifelse(male == 1, "male", "female")) 


covariates_bilendi <- c("male", "bland", "age_cat", "education")


bilendi_comp <- bilendi_comp %>% 
  mutate(across(all_of(covariates_bilendi), \(x) sjlabelled::as_label(x))) %>% 
  select(all_of(covariates_bilendi))



bilendi_comp_profile <-  map_dfr(covariates_bilendi, \(x) balance(x, df = bilendi_comp)) %>% 
  filter(!is.na(cov_value)) %>% 
  mutate(data = "Survey experiment (Bilendi)")


forsa_bilendi_comp_plot <- bind_rows(bilendi_comp_profile, 
                                     fb_comp_profile) %>%
  mutate(cov_value = ifelse(grepl("Westf", cov_value), "Nordrhein-Westfalen", cov_value)) %>% 
  mutate(cov_value = ifelse(grepl("Württ", cov_value), "Baden-Württemberg", cov_value)) %>% 
  mutate(cov_value = ifelse(covariate == "bland", gsub("\\-", "\\-\n", cov_value), cov_value)) %>% 
  
  ggplot(., aes(x = cov_value, 
                y = share, 
                group = data, 
                fill = data)) +
  geom_col(position = position_dodge2(width = 1, preserve = "single"), 
           color = "black", linewidth = 0.25) +
  geom_linerange(aes(ymin = lower_ci, ymax = upper_ci), 
                 position = position_dodge2(width = .9, preserve = "single")) + 
  geom_point(shape = 21,
             position = position_dodge2(width = .9, preserve = "single")) + 
  facet_wrap(~covariate, scales = "free", nrow = 2, 
             labeller = labeller(covariate = c("age_cat" = "Age", 
                                               "bland" = "State", 
                                               "education" = "Education",
                                               "male" = "Gender"))) +
  
  scale_fill_manual("Data source: ", values = c("grey", "white")) +
  theme_bw() + 
  theme(panel.grid = element_blank()) +
  theme(axis.text.y = element_text(size = 8), 
        legend.position = "bottom") +
  labs(x = "", y = "Share") +
  coord_flip()


forsa_bilendi_comp_plot

ggsave(forsa_bilendi_comp_plot, 
       filename = "./figures/figure_B.26_comparison_Forsa_bilendi.pdf", 
       height = 14, width = 11, scale = .7)





# Figure B.27: Attention checks samples -----------------------------------



te_mod_attention_0 <- feols(afd_pref_post ~ 
                              
                              factor(treatment) +
                              .[cov_full_pap],
                            data = bilendi_survey,
                            se = "standard")


te_mod_attention_1 <- feols(afd_pref_post ~ 
                              
                              factor(treatment) +
                              .[cov_full_pap],
                            data = bilendi_survey %>% 
                              filter(any_correct_remember_plot_fotos >= 1),
                            se = "standard")


te_mod_attention_2 <- feols(afd_pref_post ~ 
                              
                              factor(treatment) +
                              .[cov_full_pap],
                            data = bilendi_survey %>% 
                              filter(any_correct_remember_plot_fotos >= 2),
                            se = "standard")


## prep data for coefficient plot ----

main_models_df <- bind_rows(
  te_mod_attention_0 %>% broom::tidy(., conf.int = T) %>% mutate(attention_test = "no"), 
  te_mod_attention_1 %>% broom::tidy(., conf.int = T) %>% mutate(attention_test = "1"), 
  te_mod_attention_2 %>% broom::tidy(., conf.int = T) %>% mutate(attention_test = "2")
)



survey_exp_main_plot_attention_check <- main_models_df %>% 
  filter(grepl("treatment", term)) %>% 
  mutate(attention_test = fct_inorder(attention_test)) %>% 
  ggplot(., aes(x = term, 
                y = estimate, color = term)) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_point(size = 3, aes(shape = term), 
             position = position_dodge(.5)) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), 
                width = 0, linewidth = 0.25, 
                position = position_dodge(.5)) + 
  geom_errorbar(aes(ymin = estimate - 1.645 * std.error, 
                    ymax = estimate + 1.645 * std.error), 
                width = 0, linewidth = 0.7, 
                position = position_dodge(.5)) +
  labs(x = "Treatment group", 
       y = "Treatment effect estimate on AfD support") + 
 
  theme_bw() +

  scale_color_manual("", values = c("grey60", "black")) +
  scale_shape_discrete("") +
  scale_x_discrete( 
    labels = c("factor(treatment)2" = "Treatment 1:\nright-wing attack\n(no public backlash)",
               "factor(treatment)3" = "Treatment 2:\nright-wing attack\n(with public backlash)")) +
  
  facet_wrap(~attention_test, nrow = 1,scales = "free_x",
             labeller = labeller(attention_test = c("no" = "All respondents", 
                                                    "1" = "Only respondents who correctly<br>answered at least **one** attention item<br>(reported in paper)", 
                                                    "2" = "Only respondents who correctly<br>answered **two** attention items"))) +
  theme(legend.position = "none", 
        panel.grid = element_blank(),
        axis.text.x = element_text(size = 8), 
        strip.text = element_markdown()) 

survey_exp_main_plot_attention_check

ggsave(survey_exp_main_plot_attention_check, 
       filename = "./figures/figure_B.27_attention_checks.pdf", 
       width = 12, height = 5.5, scale = 0.7)



# * Newspaper analysis * --------------------------------------------------



# Figure C.28: News article content ---------------------------------------

# Create summary statistics

# Plot 
n_articles_hanau <- hanau_articles_coded %>% filter(hanau == 1) %>% nrow()
n_articles_total <- hanau_articles_coded %>% filter(missing != 1) %>% nrow()

plot_dat <-
  hanau_articles_coded %>% 
  filter(missing != 1) %>%
  mutate(afd_defense_tone_1 = as.integer(afd_defense == 1 & afd_tone == 1),
         afd_defense_tone_0 = as.integer(afd_defense == 1 & afd_tone == 0)) %>%
  select(hanau, afd_violent, afd_extremist, afd_tone, matches("afd_defense_tone")) %>%
  summarise(across(c(hanau:afd_tone, matches("afd_defense_tone")), ~ sum(.x, na.rm = T))) %>%
  mutate(hanau = hanau/n_articles_total,
         across(afd_violent:afd_defense_tone_0, ~ .x/n_articles_hanau),
  ) %>%
  pivot_longer(hanau:afd_defense_tone_0) %>%
  mutate(stack_lab = case_when(name == "afd_defense_tone_1" ~ "afd_tone_1", name == "afd_defense_tone_0" ~ "afd_tone_0",
                               T ~ "all_articles"),
         x_label = case_when(
           name == "hanau" ~ "Hanau attack mentioned",
           name == "afd_tone" ~ "AfD is resp. for\nHanau/violence ",
           name == "afd_violent" ~ "AfD incites violence",
           name == "afd_extremist" ~ "AfD as extremist",
           grepl("afd_defense", name) ~ "Defends AfD"
         ),
         x_numeric = case_when(
           x_label == "Hanau attack mentioned" ~ 1,
           x_label == "AfD is resp. for\nHanau/violence " ~ 3, 
           x_label == "AfD incites violence" ~ 4.25,   
           x_label == "AfD as extremist" ~ 5.5,
           x_label == "Defends AfD" ~ 6.75
         ),
         population = ifelse(name == "hanau", "All articles", "Articles mentioning Hanau")) 


# Precomputed scales and labels
x_breaks <- c(1, 3, 4.25, 5.5, 6.75)
x_labels <- c(
  "Hanau attack\nmentioned",
  "AfD is resp. for\nHanau/violence ", 
  "AfD incites\nviolence", 
  "AfD as\nextremist", 
  "AfD defense"
)
fill_values <- c("all_articles" = "grey40", "afd_tone_1" = "grey70", "afd_tone_0" = "grey90")
fill_labels <- c("AfD is\nresponsible", "Other articles")


# Define the y-axis limits
y_limits <- c(0, max(plot_dat$value, na.rm = TRUE)) # Set the maximum limit based on the data

# Build plots

p1 <- 
  plot_dat %>%
  filter(name == "hanau") %>%
  ggplot(aes(x = x_numeric, y = value, fill = stack_lab)) + 
  geom_col(color = "black") + 
  scale_x_continuous(breaks = x_breaks, labels = x_labels) +
  scale_y_continuous(labels = scales::percent, limits = y_limits) +
  scale_fill_manual(
    "",
    values = fill_values,
    breaks = c("afd_tone_1", "afd_tone_0"),
    labels = fill_labels,
    guide = guide_legend(ncol = 1)
  ) +
  facet_wrap(~population, scales = "free_x") +
  labs(y = "Share articles", x = "Article content") +
  theme_bw() +
  theme(
    legend.position = "bottom",
    legend.justification = c(1, 0),
    legend.margin = margin(t = -10),
    axis.text.x = element_text(angle = 0),
    panel.grid = element_blank()
  )

p2 <- 
  plot_dat %>%
  filter(name != "hanau") %>%
  ggplot(aes(x = x_numeric, y = value, fill = stack_lab)) + 
  geom_col(color = "black") + 
  scale_x_continuous(breaks = x_breaks, labels = x_labels) +
  scale_y_continuous(labels = scales::percent, limits = y_limits) +
  scale_fill_manual(
    "",
    values = fill_values,
    breaks = c("afd_tone_1", "afd_tone_0"),
    labels = fill_labels,
    guide = guide_legend(ncol = 1)
  ) +
  facet_wrap(~population, scales = "free_x") +
  labs(y = "Share articles", x = "Article content") +
  theme_bw() +
  theme(
    legend.position = "bottom",
    legend.justification = c(1, 0),
    legend.margin = margin(t = -10),
    axis.text.x = element_text(angle = 0),
    panel.grid = element_blank()
  )

# Combine plots
article_content_plot <- 
  p1 + p2 + plot_layout(widths = c(1.4, 6), axes = "collect")

ggsave("./figures/figure_C.28_news_article_content.pdf", article_content_plot,
          width = 6.5, height = 4.5)

# Figure C.29: Newspaper political leaning --------------------------------

p1 <-
  hanau_articles_pol_leaning %>% 
  filter(hanau == 1) %>%
  pivot_longer(c(afd_tone, afd_defense)) %>%
  # count(name)
  mutate(x_label = case_when(
    name == "afd_tone" ~ "AfD is resp. for\nHanau/violence ",
    name == "afd_violent" ~ "AfD incites\nviolence",
    name == "afd_extremist" ~ "AfD as\nextremist",
    name == "afd_defense" ~ "AfD defense"
  ),
  x_label = factor(x_label, levels = x_labels)) %>%
  ggplot(data = ., aes(x = x_label, y = value, group = pol_leaning)) +
  stat_summary(fun = "mean", geom = "col", aes(fill = pol_leaning), position = position_dodge(width = .7),
               width = .6, color = "black") +
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual("Political leaning\nnewspaper", values = c("grey90", "grey60", "grey30")) +
  labs(y = "Share of articles about the AfD\nand right-wing extremism\nwith specific content", x = "Article content") +
  theme_bw() +
  theme(legend.position = "bottom", panel.grid = element_blank()) 

p2 <-
  hanau_articles %>%
  count(pol_leaning, query_string) %>%
  pivot_wider(names_from = query_string, values_from = n) %>%
  mutate(across(afd_right_wing:afd_violence, ~ .x/afd)) %>%
  pivot_longer(afd_right_wing:afd_violence) %>%
  ggplot(data = ., aes(x = name, y = value, fill = pol_leaning)) + 
  geom_col(position = position_dodge(width = .7), width = .6, color = "black")  +
  scale_fill_manual("Political leaning\nnewspaper", values = c("grey90", "grey60", "grey30")) +
  scale_x_discrete(labels = c("\"AfD\" +\n\"right-wing\"", "\"AfD\" +\n\"violence\"")) +
  scale_y_continuous(labels = scales::percent) +
  labs(x = "Keywords", y = "Share of articles about the AfD\nand containing keyword") +
  theme_bw() +
  theme(legend.position = "bottom", panel.grid = element_blank()) 

pol_leaning_content <- p2 + p1 + plot_layout(guides = "collect", axes = "collect") & theme(legend.position = "bottom")

pol_leaning_content

ggsave("./figures/figure_C.29_newspaper_pol_leaning.pdf", pol_leaning_content, 
       width = 7, height = 4)

# * Tables * --------------------------------------------------------------



# Table B.1: Treatment effects on attention check -------------------------


bilendi_survey <- bilendi_survey %>% 
  mutate(treated = treatvscontrol == "treatment") %>% 
  mutate(attentive = any_correct_remember_plot_fotos >= 1, 
         inattentive = any_correct_remember_plot_fotos == 0, 
         very_attentive =  any_correct_remember_plot_fotos == 2)


attention_mod <- feols(c(attentive, 
                         very_attentive, 
                         correct_remember_fotos, 
                         correct_remember_plot) ~ 
                         
                         # sw(
                         treated
                       # 1
                       
                       # (treated) * afd_greater_than_minus_three,
                       # (treated) * I(political_interest),
                       # (treated) * I(age)
                       
                       # )
                       + sw0(.[cov_full_pap])
                       
                       ,
                       data =  bilendi_survey,
                       se = "hetero")  






models <- attention_mod

names(models) <- 1:length(models)

## coef map
my_coef_map <- c("treatedTRUE" = "Treated")

## rows
rows <- tribble( ~term,          ~model1, ~model2, ~model3,    ~model4,  ~model5,    ~model6,~model7,    ~model8,  
                 "Covariates",   "No",     "Yes",   "No",      "Yes",     "No",      "Yes",   "No",      "Yes")          

attr(rows, 'position') <- c(3:3)

options("modelsummary_format_numeric_latex" = "plain")




modelsummary(models, 
             coef_map = my_coef_map, 
             # output = "kableExtra",
             add_rows = rows, 
             estimate = "{estimate}{stars}",
             fmt = 2,
             
             gof_map = c( "r.squared", "nobs"),
             stars = T) %>% 
  group_tt(j = list(" " = 1, 
                    "At least one" = 2:3, 
                    "Two" = 4:5, 
                    "Photos" = 6:7, 
                    "Figure" = 8:9)) %>% 
  group_tt(j = list(" "  = 1, 
                    "Number of correctly answered questions" = 2:5,
                    "Correctly answered attention check about..." = 6:9)) %>% 
  save_tt("./tables/table_B.1_attention_checks.html", overwrite = T)
